package com.mouse.magent.common.util;

import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;

import java.net.InetSocketAddress;

public class NettyUtil {
    public static String getRemoteIp(ChannelHandlerContext ctx) {
        InetSocketAddress inSocket = (InetSocketAddress) ctx.channel().remoteAddress();
        String ip = inSocket.getAddress().getHostAddress();
        return ip;
    }

    public static int getLocalPort(Channel channel) {
        InetSocketAddress inSocket = (InetSocketAddress) channel.localAddress();
        return inSocket.getPort();
    }
}
